﻿using DoNetDrive.Common.Cryptography;
using System;

namespace DoNetTool.Common.Core.Web
{
    /// <summary>
    /// 网络用户验证相关
    /// </summary>
    public static class WebUserTool
    {

        private static byte[] UserKey;
        private static byte[] UserIV;
        static WebUserTool()
        {
            var sKey = "ZTJkODhhODQxZmQxNDdlOWEzYWQ0YjA4OTVhNDk5OTE=";
            var sIV = "YTdhZTMzZDlhNjhiYmQzMg==";
            UserKey = Convert.FromBase64String(sKey);
            UserIV = Convert.FromBase64String(sIV);
        }


        /// <summary>
        /// 使用网络固定密码进行加密
        /// </summary>
        /// <param name="sUser"></param>
        /// <returns></returns>
        public static string GetWebUserAESEncrypt(string sUser)
        {
            return MyAES.Encryptor(sUser, UserKey, UserIV);
        }

        /// <summary>
        /// 使用固定密码解密
        /// </summary>
        /// <param name="sUser"></param>
        /// <returns></returns>
        public static string GetWebUserAESDecrypt(string sUser)
        {
            return MyAES.Decryptor(sUser, UserKey, UserIV);
        }
    }

}
